package com.wwwc.index.web.ejb.directory;

//import com.wwwc.index.web.ejb.;
//import com.wwwc.index.web.ejb.DirectoryHomeRemote;
import java.rmi.RemoteException;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.ejb.EJBException;
import java.util.Properties;
import java.util.*;

public class DirectorySessionBean implements javax.ejb.SessionBean {

    public void ejbCreate() {}
    public void ejbRemove(){}
    public void ejbActivate(){}
    public void ejbPassivate(){}
    public void setSessionContext(javax.ejb.SessionContext cntx){}

    public ArrayList getDirectoryList() {
	try {
	    javax.naming.Context jndiContext = new InitialContext();
	    Object obj = jndiContext.lookup("java:comp/env/ejb/DirectoryEntityEJBRef");
	    DirectoryEntityBeanHome home = null;
	    home = (DirectoryEntityBeanHome)javax.rmi.PortableRemoteObject.narrow(obj,DirectoryEntityBeanHome.class);
	    ArrayList a = new ArrayList();
	    Collection rs = home.findRecordsByGroup();
	    Iterator it = rs.iterator();
	    while (it.hasNext()) {
		DirectoryEntityBeanRemote dr = (DirectoryEntityBeanRemote)it.next();
		ArrayList aa = new ArrayList();
		aa.add(dr.getF0());
		aa.add(dr.getF1());
		aa.add(dr.getF2());
		aa.add(dr.getF3());
		aa.add(dr.getF4());
		aa.add(dr.getF5());
		aa.add(dr.getF6());
		aa.add(dr.getF7());
		aa.add(dr.getF8());
		aa.add(dr.getF9());
		a.add(aa);
	    }
	    return a;
	} 
	catch(Exception e) {
	    throw new EJBException(e);
	}    
    }
}

